friends = []

while True:
    name = input("Enter your friend's name (or 'd' to finish): ")
    if name == 'd':
        break
    friends.append(name)

print("You have entered {} friends.".format(len(friends)))
print("Here is your list of friends:")
for i, name in enumerate(friends, start=1):
    print(f"{i}. {name}")

import random
if len(friends) >= 2:
    chosen_friends = random.sample(friends, 2)
    print("The two friends chosen to go to the movies with you are:")
    for friend in chosen_friends:
        print(friend)
else:
    print("Not enough friends to choose from.")

best_friends = []
while True:
    print("\nWhich friends would you like to move to your Best Friends List?")
    print("Enter the number next to their name, or '0' to finish:")
    for i, name in enumerate(friends, start=1):
        print(f"{i}. {name}")
    choice = int(input("Your choice: "))
    if choice == 0:
        break
    if 1 <= choice <= len(friends):
        best_friends.append(friends.pop(choice - 1))
    else:
        print("Invalid choice, please try again.")

print("\nHere is your updated list of friends:")
for i, name in enumerate(friends, start=1):
    print(f"{i}. {name}")

print("\nHere is your list of best friends:")
for i, name in enumerate(best_friends, start=1):
    print(f"{i}. {name}")
